/**
 * 
 */
package com.surfilter.code.gen.task;

import javax.swing.JOptionPane;

import org.apache.tools.ant.Task;

import com.surfilter.code.gen.tool.CodeGenTools;

/**
 * Description: 生成Js代码task
 */
public class JsCodeGenTask extends Task{

    private String dataSource;
    
    private String jsPrefix;
    
    private String jsModPath;
    
    private String pattern;

    private String javaModPath;
    
    private String pkg;
    
    private String isCover;

	public String getIsCover() {
		return isCover;
	}

	public void setIsCover(String isCover) {
		this.isCover = isCover;
	}
    
    public String getDataSource() {
		return dataSource;
	}

	public void setDataSource(String dataSource) {
		this.dataSource = dataSource;
	}

	public String getJsPrefix() {
		return jsPrefix;
	}

	public void setJsPrefix(String jsPrefix) {
		this.jsPrefix = jsPrefix;
	}

	public String getJsModPath() {
		return jsModPath;
	}

	public void setJsModPath(String jsModPath) {
		this.jsModPath = jsModPath;
	}

	public String getPattern() {
		return pattern;
	}

	public void setPattern(String pattern) {
		this.pattern = pattern;
	}

	public void execute() {
		
        try {
        	CodeGenTools instance = new CodeGenTools(this.dataSource, this.jsPrefix, this.jsModPath, this.pattern, this.javaModPath, this.pkg, Boolean.parseBoolean(this.isCover),null);
        	instance.genJsCode(this);
        } catch (Throwable e) {
        	JOptionPane.showMessageDialog(null, "生成JS代码发生错误," + e.getMessage());
            e.printStackTrace();
        }
    }
}
